home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
726-750
/
729
/
ff
/
source
/
gui.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-18
|
8KB
|
281 lines
/*
* Source generated with GadToolsBox V1.3
* which is (c) Copyright 1991,92 Jaba Development
*/
#define GT_Underscore (GT_TagBase+64)
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <string.h>
#include "GUI.h"
struct Screen *Scr = NULL;
APTR VisualInfo = NULL;
struct Window *Project0Wnd = NULL;
struct Gadget *Project0GList = NULL;
struct Menu *Project0Menus = NULL;
struct Gadget *Project0Gadgets[10];
UWORD Project0Left = 3;
UWORD Project0Top = 12;
UWORD Project0Width = 333;
UWORD Project0Height = 185;
UBYTE *Project0Wdt = (UBYTE *)"FindFile V1.01";
extern struct GfxBase *GfxBase;
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
struct NewMenu Project0NewMenu[] = {
NM_TITLE, (STRPTR)"File", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Save Filelist", NULL, 0, 0L, NULL,
NM_SUB, (STRPTR)"Full paths", (STRPTR)"S", 0, 0L, NULL,
NM_SUB, (STRPTR)"Names only", (STRPTR)"A", 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"About...", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Quit", (STRPTR)"Q", 0, 0L, NULL,
NM_TITLE, (STRPTR)"Copy", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Filename", NULL, 0, 0L, NULL,
NM_SUB, (STRPTR)"Full path", (STRPTR)"P", 0, 0L, NULL,
NM_SUB, (STRPTR)"Name only", (STRPTR)"N", 0, 0L, NULL,
NM_ITEM, (STRPTR)"File list", NULL, 0, 0L, NULL,
NM_SUB, (STRPTR)"Full paths", (STRPTR)"L", 0, 0L, NULL,
NM_SUB, (STRPTR)"Names only", (STRPTR)"O", 0, 0L, NULL,
NM_END, NULL, NULL, 0, 0L, NULL };
static UWORD ComputeX( UWORD value )
{
return(( UWORD )(( FontX * value ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )(( FontY * value ) / 8 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Font = &Attr;
Font->ta_Name = GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
FontX = GfxBase->DefaultFont->tf_XSize;
OffY = Scr->Font->ta_YSize + Scr->WBorTop + 1;
OffX = Scr->WBorLeft;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( NULL )))
return( 1L );
ComputeFont( 0L, 0L );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
UnlockPubScreen( NULL, Scr );
Scr = NULL;
}
}
int OpenProject0Window( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD wleft = Project0Left, wtop = Project0Top, ww, wh;
ComputeFont( Project0Width, Project0Height );
ww = ComputeX( Project0Width );
wh = ComputeY( Project0Height );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &Project0GList )))
return( 1L );
ng.ng_LeftEdge = OffX + ComputeX( 91 );
ng.ng_TopEdge = OffY + ComputeY( 2 );
ng.ng_Width = ComputeX( 239 );
ng.ng_Height = ComputeY( 13 );
ng.ng_GadgetText = (UBYTE *)"Search _for";
ng.ng_TextAttr = Font;
ng.ng_GadgetID = GD_Pattern;
ng.ng_Flags = PLACETEXT_LEFT;
ng.ng_VisualInfo = VisualInfo;
g = CreateGadget( STRING_KIND, g, &ng, GTST_String, "#?", GTST_MaxChars, 256, GT_Underscore, '_', TAG_DONE );
Project0Gadgets[ 0 ] = g;
ng.ng_TopEdge = OffY + ComputeY( 16 );
ng.ng_Width = ComputeX( 180 );
ng.ng_GadgetText = (UBYTE *)"_Directory ";
ng.ng_GadgetID = GD_Dir;
g = CreateGadget( STRING_KIND, g, &ng, GTST_MaxChars, 256, GT_Underscore, '_', TAG_DONE );
Project0Gadgets[ 1 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 3 );
ng.ng_TopEdge = OffY + ComputeY( 30 );
ng.ng_GadgetText = (UBYTE *)"Search su_bdirectories";
ng.ng_GadgetID = GD_Recur;
ng.ng_Flags = PLACETEXT_RIGHT;
g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, GT_Underscore, '_', TAG_DONE );
Project0Gadgets[ 2 ] = g;
ng.ng_TopEdge = OffY + ComputeY( 42 );
ng.ng_GadgetText = (UBYTE *)"And directory _links";
ng.ng_GadgetID = GD_Links;
g = CreateGadget( CHECKBOX_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
Project0Gadgets[ 3 ] = g;
ng.ng_TopEdge = OffY + ComputeY( 170 );
ng.ng_Width = ComputeX( 73 );
ng.ng_Height = ComputeY( 13 );
ng.ng_GadgetText = (UBYTE *)"_Go";
ng.ng_GadgetID = GD_Go;
ng.ng_Flags = PLACETEXT_IN;
g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
Project0Gadgets[ 4 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 257 );
ng.ng_GadgetText = (UBYTE *)"_Stop";
ng.ng_GadgetID = GD_Stop;
g = CreateGadget( BUTTON_KIND, g, &ng, GA_Disabled, TRUE, GT_Underscore, '_', TAG_DONE );
Project0Gadgets[ 5 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 273 );
ng.ng_TopEdge = OffY + ComputeY( 16 );
ng.ng_Width = ComputeX( 57 );
ng.ng_GadgetText = (UBYTE *)"B_rowse";
ng.ng_GadgetID = GD_Browse;
g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
Project0Gadgets[ 6 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 3 );
ng.ng_TopEdge = OffY + ComputeY( 55 );
ng.ng_Width = ComputeX( 327 );
ng.ng_Height = ComputeY( 60 );
ng.ng_GadgetText = NULL;
ng.ng_GadgetID = GD_FileList;
ng.ng_Flags = 0;
g = CreateGadget( LISTVIEW_KIND, g, &ng, GTLV_Labels, NULL,TAG_DONE );
Project0Gadgets[ 7 ] = g;
ng.ng_TopEdge = OffY + ComputeY( 116 );
ng.ng_Height = ComputeY( 52 );
ng.ng_GadgetID = GD_DirList;
g = CreateGadget( LISTVIEW_KIND, g, &ng, GTLV_Labels, NULL, GTLV_ReadOnly, TRUE, TAG_DONE );
Project0Gadgets[ 8 ] = g;
ng.ng_LeftEdge = OffX + ComputeX( 226 );
ng.ng_TopEdge = OffY + ComputeY( 42 );
ng.ng_GadgetText = (UBYTE *)"_Wildcards";
ng.ng_GadgetID = GD_Wildcards;
ng.ng_Flags = PLACETEXT_RIGHT;
g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, GT_Underscore, '_', TAG_DONE );
Project0Gadgets[ 9 ] = g;
if ( ! g )
return( 2L );
if ( ! ( Project0Menus = CreateMenus( Project0NewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
return( 3L );
LayoutMenus( Project0Menus, VisualInfo, TAG_DONE );
if ( ! ( Project0Wnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, STRINGIDCMP|CHECKBOXIDCMP|BUTTONIDCMP|LISTVIEWIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, Project0GList,
WA_Title, Project0Wdt,
WA_ScreenTitle, "FindFile V1.01 ©1992 Dave Schreiber",
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
SetMenuStrip( Project0Wnd, Project0Menus );
GT_RefreshWindow( Project0Wnd, NULL );
return( 0L );
}
void CloseProject0Window( void )
{
if ( Project0Menus ) {
ClearMenuStrip( Project0Wnd );
FreeMenus( Project0Menus );
Project0Menus = NULL; }
if ( Project0Wnd ) {
CloseWindow( Project0Wnd );
Project0Wnd = NULL;
}
if ( Project0GList ) {
FreeGadgets( Project0GList );
Project0GList = NULL;
}
}